home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_11
/
8n11106c
< prev
next >
Wrap
Text File
|
1990-08-07
|
686b
|
27 lines
char buffer[1000];
int length;
char *pc;
FILE *file;
file = fopen("CHARDATA.DAT","r");
for (i = 0; i < 200; i++)
{
/* For each element */
/* Read one line */
fgets(buffer, 1000, file);
/* Determine the length */
length = strlen(buffer);
/* Put a NUL character over the new-line '\n' */
buffer[length - 1] = 0;
/* Allocate space for the string */
pc = malloc(length);
/* Copy the string */
strcpy(pc, buffer);
/* Assign the pointer to an element */
OBJECT[i].Element_1 = pc;
/* Begin repetition for next element */
...
}